<template>
    <div style="width: 100%;margin-top: 20%;">
        <h4>宣钢库存管理系统</h4>
        <el-form ref="form" :model="form" label-width="100px" style="margin-top: 10%;">
            <el-form-item label="用户名" style="width:90%;font-size: 0.37rem;font-weight: bold">
                <el-input v-model="form.in0"></el-input>
            </el-form-item>
            <el-form-item label="密码" style="width: 90%;font-size: 0.37rem;font-weight: bold">
                <el-input v-model="form.in1" show-password></el-input>
            </el-form-item>
        </el-form>
        <el-button  plain style="margin-right: 5%;" @click="Login()">登录</el-button>
        <el-button  plain @click="resize()">重置</el-button>
    </div>


</template>

<script>
// import userservice from "../service/userservice";
import $ from 'jquery';
import 'jquery.soap';
export default {
    name: 'HelloWorld',
    props: {
        msg: String
    },
    data() {
        return {
            form: {
                in0: "",
                in1: ''

            }
        }
    },
    methods: {
        Login() {
            var that =this;
            $.soap({
                url: '/api/pdaservices/services/user?',
                method: 'checkUser',
                data: {
                    in0: this.form.in0,
                    in1: this.form.in1
                },
                success: function (soapResponse) {
                    var val = soapResponse.content.all;
                    var arr = [];
                    for (var i = 0; i < val.length; i++) {
                        if (val[i].nodeName == "xsd:anyType") {
                            arr.push(val[i].innerHTML)
                        }
                    }
                    if (arr[0] == 0) {
                        alert("用户名或密码错误")
                    } else if(arr[0] == 1){
                        sessionStorage.setItem('LoginUser',arr);
                        // window.location.href='http://192.168.35.98:8080/Page1'
                        // window.location.href='http://localhost:8080/Page1'
                        that.$router.push('/Page1')
                    }else{
                        alert('网络错误')
                    }

                },
                error: function (SOAPResponse) {
                    // show error
                    console.log(SOAPResponse, '2')
                }
            });
        },
        resize() {
            this.form.in0 = '';
            this.form.in1 = '';
        }
    },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped></style>
